package com.bifang.module.file.gateway.controller;

import com.bifang.module.file.common.vo.fileAppClass.FileAppClassVO;
import com.bifang.module.file.core.biz.FileAppReadIntegration;
import com.bifang.module.file.common.vo.fileAppRead.FileAppReadVO;
import com.bifang.module.file.common.vo.fileAppRead.FileAppReadKeyVO;
import com.bifang.module.file.common.vo.fileAppRead.FileAppReadQueryVO;
import com.github.pagehelper.PageInfo;
import com.bifang.engine.assistant.core.domain.AppResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
import com.bifang.engine.protect.core.annotation.Idempotent;
import org.springframework.validation.annotation.Validated;
import com.bifang.assistant.common.constants.Validators;

/**
 * 应用读取文件权限表网关
 *
 * @author xyh
 * @since 2023-03-17
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "应用读取文件权限表", description = "应用读取文件权限表")
public class FileAppReadController {

    @Autowired
    public FileAppReadIntegration fileAppReadIntegration;

    @Operation(summary = "应用读取文件权限表分页查询",description = "应用读取文件权限表分页查询")
    @PostMapping(value = "/fileAppRead0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<FileAppReadVO>> getList(@RequestBody @Validated FileAppReadQueryVO vo) {
        return AppResponse.successData(fileAppReadIntegration.getList(vo));
    }

    @Operation(summary = "应用读取文件权限表根据主键查询详情",description = "应用读取文件权限表根据主键查询详情")
    @PostMapping(value = "/fileAppRead0002", produces = "application/json;charset=UTF-8")
    public AppResponse<FileAppReadVO> getById(@RequestBody @Validated FileAppReadKeyVO vo) {
        return AppResponse.successData(fileAppReadIntegration.getById(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "应用读取文件权限表新增",description = "应用读取文件权限表新增")
    @PostMapping(value = "/fileAppRead0004", produces = "application/json;charset=UTF-8")
    public AppResponse<FileAppReadVO> add(@RequestBody @Validated(value = {Validators.Add.class}) FileAppReadVO vo) {
        return AppResponse.successData(fileAppReadIntegration.add(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "应用读取文件权限表修改",description = "应用读取文件权限表修改")
    @PostMapping(value = "/fileAppRead0005", produces = "application/json;charset=UTF-8")
    public AppResponse<FileAppReadVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) FileAppReadVO vo) {
        return AppResponse.successData(fileAppReadIntegration.edit(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "应用读取文件权限表删除",description = "应用读取文件权限表删除")
    @PostMapping(value = "/fileAppRead0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated FileAppReadKeyVO vo) {
        fileAppReadIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }

    @Operation(summary = "文件应用分类授权管理分页查询",description = "文件应用分类授权管理分页查询")
    @PostMapping(value = "/fileAppRead0007", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<FileAppClassVO>> getFileAppClassList(@RequestBody @Validated FileAppReadQueryVO vo) {
        return AppResponse.successData(fileAppReadIntegration.getFileAppClassList(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "应用读取文件权限表批量新增",description = "应用读取文件权限表批量新增")
    @PostMapping(value = "/fileAppRead0008", produces = "application/json;charset=UTF-8")
    public AppResponse addBatch(@RequestBody @Validated(value = {Validators.Add.class}) FileAppReadVO vo) {
         fileAppReadIntegration.addBatch(vo);
        return AppResponse.success();
    }

}
